package com.yantong.mapper;

import com.yantong.pojo.TicketRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author kanghaixin
 */
public interface TicketRecordMapper {

    /**
     * 主键删除
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Long id);

    /**
     * 新增
     * @param record
     * @return
     */
    int insertSelective(TicketRecord record);

    /**
     * 详情
     * @param id
     * @return
     */
    TicketRecord selectByPrimaryKey(Long id);

    /**
     * 更新
     * @param record
     * @return
     */
    int updateByPrimaryKeySelective(TicketRecord record);

    int updateByOrderSelective(TicketRecord record);

    /**
     * 条件统计
     * @param params
     * @return
     */
    int countByParams(Map<String, Object> params);

    /**
     * 条件查询
     * @param params
     * @param rowBounds
     * @return
     */
    List<TicketRecord> listByParams(Map<String, Object> params, RowBounds rowBounds);

    /**
     * 条件查询(时间区间)
     * @param params
     * @return
     */
    List<TicketRecord> listByParamsByTime(Map<String, Object> params);

    /**
     * 根据主键查询优惠券详细信息
     * @param trId
     * @return
     */
    TicketRecord getByKey(Long trId);

    TicketRecord getByKeyAllStatus(Long trId);

    /**
     * 检查已经失效的优惠券记录
     * @return
     */
    int checkTicketRecord();

    /**
     * 查询已经失效的优惠券记录
     *
     * @param
     * @return java.util.List<com.jz.promotion.domain.TicketRecord>
     * @author huangshuai
     * @date 2021/5/6 16:37
     */
    List<TicketRecord> getInvalidationTicketRecordlist();

    /**
     * 获取满足条件的订单优惠券
     * @param params
     * @return
     */
    List<TicketRecord>  getTicketRecords(Map<String, Object> params);

    /**
     * 获取满足条件的订单优惠券
     * @param params
     * @return
     */
    List<TicketRecord>  getDetermineTicketRecords(Map<String, Object> params);

    /**
     * 根据优惠卷Id和用户Id得到优惠卷领取信息
     * @param params
     * @return
     */
    TicketRecord getTicketRecordsByParam(Map<String, Object> params);

    /**
     * 统计会员已拥有指定优惠券数量
     * @param mid
     * @param ticketId
     * @return
     */
    int countMidTicket(@Param("mid") Long mid, @Param("ticketId") Long ticketId);

    /**
     * 根据会员id,优惠券id查询是否有优惠券
     * @param queryMap1
     * @return
     */
    List<TicketRecord> selMemberIdTicket(Map<String, Object> queryMap1);

    void insertSelectiveBatch(@Param("list") List<TicketRecord> list);

	String sumTicketByOrderId(Long orderId);

	BigDecimal getSumTicketAmount(Map params);

    List<TicketRecord> getLocalLifShopCoupon(Long shopMemberId);
}